package com.wuhongyu.common;

import com.wuhongyu.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.*;


/**
 * springboot的配置文件
 */
@Configuration
public class SpringBootConfig implements WebMvcConfigurer {

    /**
     * 这个坑有点大呀.....
     * 这个拦截器默认拦截所有静态资源...然而静态资源在网页上访问的时候不用写/static/....
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**").excludePathPatterns(
                "/login","logout","/toLogin","*.css","*.js","/images/**"
        );
    }

    /**
     *设置项目的首页
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/login");
    }
}